<template>
  <view class="menuDouble">
    <!-- <u-dropdown ref="uDropdown"  @change="change">
			<u-dropdown-item v-model="value1" title="全部商户"  active-color='#02af74' :options="options1"></u-dropdown-item>
			<u-dropdown-item v-model="value2" title="全部设备" active-color='#02af74'  :options="options2"></u-dropdown-item>
		         </u-dropdown> -->
    <u-dropdown ref="uDropdown">
      <u-dropdown-item
        v-model="value1"
        :title="value1"
        :options="options1"
        @change="change"
      ></u-dropdown-item>
      <u-dropdown-item
        v-model="value2"
        :title="value2"
        :options="options2"
        @change="changeOption2"
      ></u-dropdown-item>
    </u-dropdown>
  </view>
</template>

<script  lang='ts'>
import { Component, Prop, Vue, Watch, Emit } from "vue-property-decorator";
import { findMaintainOrderList , findTerminalBox} from "../../utils/uniApi";

import Unavbar from "../../uview-ui/components/u-navbar/u-navbar.vue";
import uPicker from "../../uview-ui/components/u-picker/u-picker.vue";

@Component({
  //   @Component  是一个装修器   不可以在下面写语句
  name: "test",
  components: {
    "u-navbar": Unavbar,
    "u-picker": uPicker,
  },
})
export default class extends Vue {
  public value1 = "全部商户";
  public value2 = "全部设备";

  public options1: any = [
    // {
    //   label: "暂无数据",
    //   value: 1,
    // },
  ];
  public options2: any = [
    // {
    //   label: "暂无数据",
    //   value: 1,
    // },
  ];
  public sn:any =''

  public shopId:any=''
  public allData:any=''


   findTerminalBox() {

  uni.showLoading({
	title: '加载中'
});
    let param = {
      shopId:'',
      userId:
        uni.getStorageSync("userId") == ""
          ? ""
          : parseInt(uni.getStorageSync("userId")),
    };
    // findTerminalBox(param).then((res: any) => {
    //   console.log(res, "ress设备下拉");
    //     res.data.data.filter((item:any,index:any)=>{
    //       // console.log(item.shopName,index)
    //       let obj:object={  
    //       label:item.sn,  //设备名
    //       value:index,  //索引
    //       id:item.id    //设备id
    //       }
    //       this.options2.push(obj)
    //       uni.hideLoading();
    //     })
    // });
  }

  change(index: any) {
    console.log(index, "11111333");
    // this.value1=index

    this.allData= [];
    this.options1.filter((item: any, indexd: any) => {
      console.log(item.label, "item.shopName", index, indexd);

      if (item.value == index) {
        console.log(item.label, "item.shopName");
        this.value1 = item.label;
        this.shopId = item.id;
        console.log("this.shopIdthis.shopId", this.shopId);

        // this.accordingM();

      }
    });
  }

  changeOption2(index: any) {
    console.log(index, "2222");
    this.options2.filter((item: any, indexd: any) => {
      console.log(item.label, "item.shopName", index, indexd);
      if (item.value == index) {
        console.log(item.label, "item.shopName");
        this.value2 = item.label;

        this.sn = item.label;
        console.log(this.sn, " this.sn this.sn this.sn");
        // this.accordingM();
      }
    });
  }
}
</script>

<style lang="less" scoped>
</style>